#ifndef _SENDTCPRESET_
#define _SENDTCPRESET_

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <arpa/inet.h>
#include "SwafStructs.h"

#define SOCKET_ERROR -1
#define IPVER 4
#define DEF_TTL 255
#define DEF_OFFSET 5
#define DEF_WIN 512
#define URG 0x20
#define ACK 0x10
#define PSH 0x08
#define RST 0x04
#define SYN 0x02
#define FIN 0x01
#define PSEUDOSIZE (sizeof(pseudo)+sizeof(struct tcp_header))
#define PACKETSIZE (sizeof(struct ip_header)+sizeof(struct tcp_header))

u_short checksum(u_short *buffer, int size);
int sendTCPpacket(u_short src_port,u_short dest_port,const char *s_ip,const char *d_ip,unsigned int);
void create_ip(struct ip_header *hdr, struct in_addr srcaddr, struct in_addr destaddr, u_short id, u_char ttl);
void create_tcp(struct tcp_header *hdr, u_short srcport, u_short destport, struct in_addr srcaddr, struct in_addr destaddr, u_int seq, u_int ack, u_char flags, u_short win);

struct ip_header
{
 u_char len:4, ver:4;
 u_char tos;
 u_short tot_len;
 u_short id;
 u_short ip_off;
 u_char ttl;
 u_char proto;
 u_short sum;
 u_int src_addr;
 u_int dest_addr;
};

struct tcp_header
{
 u_short src_port;
 u_short dest_port;
 u_int seq;
 u_int ack;
 u_char th_x2:4, offset:4;
 u_char flags;
 u_short window;
 u_short sum;
 u_short th_urp;
};

struct pseudohdr {
  struct in_addr src_addr;
  struct in_addr dest_addr;
  u_char zero;
  u_char protocol;
  u_short length;
} pseudo;

#endif//_SENDTCPRESET_


